package com.huayun.plugin.separationsurface.controller;

import com.huayun.plugin.common.R;
import com.huayun.plugin.separationsurface.domain.ProjectSurface;
import com.huayun.plugin.separationsurface.service.SeparationSurfaceService;
import com.huayun.plugin.separationsurface.vo.SeparationSurfaceParam;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/separationSurface")
@RequiredArgsConstructor
public class SeparationSurfaceController {

    private final SeparationSurfaceService separationSurfaceService;

    /**
     * 增加分离面
     * @param param
     * @return
     */
    @PostMapping("addSeparationSurface")
    public R<?> addSeparationSurface(@RequestBody SeparationSurfaceParam param) {
        ProjectSurface surface = separationSurfaceService.addSeparationSurface(param);
        return R.<ProjectSurface>builder().data(surface).success().build();
    }

    /**
     * 获取分离面
     * @param assemblyIds   装配下获取内部实例的分离面
     * @param projectId     项目编码
     * @param activeDocId   文档信息
     * @return
     */
    @PostMapping("getSeparationSurfaces")
    public R<?> getSeparationSurfaces(@RequestParam List<String> assemblyIds, String projectId, String activeDocId) {
        List<ProjectSurface> separationSurfaces =
                separationSurfaceService.getSeparationSurfaces(projectId, activeDocId, assemblyIds);
        return R.<List<ProjectSurface>>builder().data(separationSurfaces).success().build();
    }

    /**
     * 删除分离面
     * @param delIds
     * @return
     */
    @PostMapping("deleteSeparationSurfaces")
    public R<?> deleteSeparationSurfaces(@RequestParam List<String> delIds) {
        separationSurfaceService.deleteSeparationSurfaces(delIds);
        return R.<String>builder().data("").success().build();
    }


}
